package core.command
{
	import core.data.DataBase;
	import core.event.EventID;
	import core.event.UnoEvent;
	import core.listener.GlobalListener;
	
	import flash.events.Event;
	
	public class SuperCommand implements ICommand
	{
		public var socketEvent:String = "";
		public var viewEvent:String = "";
		
		protected var db:DataBase = DataBase.getInstance();
		protected var dispatch:GlobalListener = GlobalListener.getInstance();
		
		public function SuperCommand()
		{
			
		}
		
		protected function dispatchUpdateEvent(e:UnoEvent):void
		{
			if(viewEvent != "")
			{
				dispatch.dispatchEvent(new UnoEvent(viewEvent,e.data,e.status));
			}
		}
		
		public function success(e:UnoEvent):void
		{
			
		}
		
		public function fail(e:UnoEvent):void
		{
			
		}
		
		public function command(e:UnoEvent):void
		{
			if(e.status=="1")
			{
				success(e);
			}else{
				fail(e);
			}
			dispatchUpdateEvent(e);
			dispatch.dispatchEvent(new Event(EventID.DEBUG_OUTPUT));
		}
	}
}